import { h, type Component } from 'vue'
import { RouterLink } from 'vue-router'
import { NIcon, type MenuOption } from 'naive-ui'

import {
    DisplaySettingsFilled,
    HomeRound,
    PersonOutlineFilled,
    FolderOpenFilled,
    PersonOutlineOutlined,
    NotStartedOutlined,
    PersonPinOutlined,
    GroupOutlined,
    FileCopyOutlined,
    PersonOutlineTwotone,
    PersonPinCircleOutlined,
    DisplaySettingsOutlined,
    AdminPanelSettingsOutlined
} from '@vicons/material'

export const menuOptions: MenuOption[] = [
    {
        label: () => h(RouterLink, { to: { name: 'dashboard' } }, { default: () => '仪表台' }),
        key: 'dashboard',
        icon: renderIcon(HomeRound)
    },
    { key: 'devider', type: 'divider' },
    {
        label: () => h(RouterLink, { to: { name: 'globalsetting' } }, { default: () => '全局设置' }),
        key: 'globalsetting',
        icon: renderIcon(DisplaySettingsOutlined)
    },
    {
        label: () => h(RouterLink, { to: { name: 'folder' } }, { default: () => '目录管理' }),
        key: 'folder',
        icon: renderIcon(FolderOpenFilled)
    },

    {
        // label: () => h(RouterLink, { to: { name: 'localuser' } }, { default: () => '用户管理' }),
        key: 'user',
        label: '用户管理T',

        icon: renderIcon(PersonOutlineFilled),
        children: [
            {
                label: () =>
                    h(RouterLink, { to: { name: 'globaluser' } }, { default: () => '用户全局权限设置' }),
                key: 'globaluser',
                icon: renderIcon(AdminPanelSettingsOutlined)
            },
            {
                label: () => h(RouterLink, { to: { name: 'localuser' } }, { default: () => '本地用户' }),
                key: 'localuser',
                icon: renderIcon(PersonPinCircleOutlined)
            },
            {
                label: () =>
                    h(RouterLink, { to: { name: 'virtualuser' } }, { default: () => '虚拟用户Todo' }),
                key: 'virtualuser',
                icon: renderIcon(PersonOutlineTwotone)
            },
            {
                label: () => h(RouterLink, { to: { name: 'anonymous' } }, { default: () => '匿名用户' }),
                key: 'anonymous',
                icon: renderIcon(PersonPinOutlined)
            }
        ]
    },
    {
        label: () => h(RouterLink, { to: { name: 'group' } }, { default: () => '用户组管理T' }),
        key: 'group',
        icon: renderIcon(GroupOutlined)
    },
    {
        label: () => h(RouterLink, { to: { name: 'log' } }, { default: () => '日志查询' }),
        key: 'log',
        icon: renderIcon(DisplaySettingsFilled)
    },
    {
        label: () => h(RouterLink, { to: { name: 'config' } }, { default: () => '配置文件' }),
        key: 'config',
        icon: renderIcon(FileCopyOutlined)
    },
]

function renderIcon(icon: Component) {
    return () => h(NIcon, null, { default: () => h(icon) })
}
